<template>
  <div v-if="data" class="w-subtitle" :class="{ 'immerse-mode': !clearScreen.footFlag && !ttsa.controller }">
    <div class="wrapper">
      <svg-icon name="subtitle-arrow" class="subtitle-arrow inline-block" />
      <div class="text inline-block min-h-10px">
        {{ shakeWord }}
      </div>
      <svg-icon name="subtitle-arrow" class="subtitle-arrow subtitle-arrow-right inline-block" />
    </div>
  </div>
</template>
<script
  lang="ts"
  setup
  name="SubtitlePc"
>
import { useTtsaStore } from '@/store/ttsa';
import useSubtitle from './hook'
import { useConfigStore } from "@/store/config";

const ttsa = useTtsaStore();
const config = useConfigStore()

const clearScreen = computed(() => config.clearScreen)

const props = defineProps({
  data: {
    type: String,
    default: '',
    required: true,
  }
});


const { shakeWord } = useSubtitle(props)

</script>

<style lang="scss" scoped>
@keyframes blink {
  0% {
    background-color: white;
  }

  50% {
    background-color: transparent;
  }

  100% {
    background-color: white;
  }
}

.w-subtitle {
  @apply flc absolute text-white;
  font-size: 16px;
  width: 1080px;
  left: 50%;
  height: 38px;
  line-height: 38px;
  bottom: 165px;
  margin-left: -540px;
  text-align: center;
  font-weight: 500;
  letter-spacing: 1px;
  text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.3);
  user-select: none;
  transition: bottom 0.6s ease-out;

  .wrapper {
    @apply backdrop-filter backdrop-blur-[8px] inline-block transform-gpu;
    position: relative;
    // background: linear-gradient(90deg, rgba(178, 189, 205, 0) 0%, rgba(65, 77, 90, 0.4) 52%, rgba(122, 136, 158, 0) 100%);
    background: linear-gradient(90deg, rgba(166, 193, 231, 0) 0%, rgba(117, 153, 191, 0.8) 53%, rgba(150, 177, 219, 0) 100%);
    border-radius: 30px;
    text-shadow: 0px 2px 4px rgba(89, 130, 163, 0.5);
    padding: 0 20px 0 50px;

    &::before {
      content: '';
      position: absolute;
      top: 10;
      right: 0;
      left: 0;
      width: 80%;
      height: 1px;
      margin: 0 auto;
      background-image: url('@/assets/images/pc/line.svg');
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
    }
  }


  .text {
    @apply inline-block relative;
    padding: 0 75px 0 35px;

    &::after {
      @apply absolute bg-white;
      content: '';
      top: 50%;
      right: 68px;
      width: 2px;
      height: 15px;
      transform: translateY(-50%);
      animation: blink 1s infinite steps(1, start);
    }
  }

  .subtitle-arrow {
    width: 19px;
    height: 19px;
    left: 50%;
    vertical-align: text-bottom;
  }

  .subtitle-arrow-right {
    transform: translateX(-40px) rotate(-180deg);
  }
}

.immerse-mode {
  bottom: 105px;
}
</style>

